from functools import wraps

def coroutine(f):
    @wraps(f)
    def wrapper(*args,**kwargs):
        g=f(*args,**kwargs)
        next(g)
        return g
    return wrapper

@coroutine
def generator():
    l=[]
    while True:
        value=yield
        if value == 'CLOSE':
            break
        l.append(value)
    return l

k=generator()
for i in ('hello','world','CLOSE'):
    try:
        k.send(i)
    except StopIteration as e:
        value=e.value
        print('END')
print(value)
